package handlers

import (
	"encoding/json"
	"fmt"
	"net/http"
)

//最终结果
func (c *Controller) Desc(w http.ResponseWriter, r *http.Request) {

	phone := r.FormValue("phone")
	gender := r.FormValue("gender")
	rs := []rune(phone)
	numbers := make([]string, 0)
	for _, num := range rs {
		numbers = append(numbers, string(num))
	}
	//计算描述结果
	list := c.Svc.Descs(numbers, gender)
	bytes, err := json.Marshal(list)
	if err != nil {
		fmt.Println("序列化失败:", err)
	}
	w.Write(bytes)
}
